import { getPlaylistTrackAll_api } from "@/api/homePage"
import { onMounted, shallowRef } from "vue"

export const useSongList_api = (id: string) => {
    const playListTrackAll: any = shallowRef([])
    const getPlayListTrackAll = () => {
        getPlaylistTrackAll_api({ id }).then((res: any) => {
            playListTrackAll.value = res.songs.map((el: any) => ({
                id: el.id,
                name: el.name,
                author: el.ar.map((item: any) => item.name).join('/'),
                picUrl: el.al.picUrl,
                albumName: el.al.name,
                albumId: el.al.id,
                publishTime: el.publishTime
            }))
        })
    }
    onMounted(() => {
        getPlayListTrackAll()
    })
    return {
        playListTrackAll
    }
}